﻿

package  org.nickro.effects
{
	import flash.geom.Matrix;
	import flash.display.*;
	import flash.events.Event;

	public class shade extends Sprite {
		public function shade(sta:Sprite):void {
			sta.addChild(this);

		}

		 public function makeshade(realobj:Object,shadeobj:Object,dire_x:Boolean=true):void {

			var temp_matrix:Matrix=realobj.transform.matrix.clone();
			var flip_axis:Number=dire_x?stage.stageHeight/2:stage.stageWidth/2;
			var flip_matrix:Matrix=dire_x?new Matrix(1,0,0,-.8,0,0):new Matrix(-1,0,0,.8,0,0);

			if (dire_x) {
				temp_matrix.ty-=(flip_axis);
				temp_matrix.concat(flip_matrix);
				temp_matrix.ty+=flip_axis;
				shadeobj.transform.matrix=temp_matrix;
				shadeobj.alpha=1-0.8*(shadeobj.y-realobj.y)/flip_axis;
			} else {
				temp_matrix.tx-=(flip_axis);
				temp_matrix.concat(flip_matrix);
				temp_matrix.tx+=flip_axis;
				shadeobj.transform.matrix=temp_matrix;
				shadeobj.alpha=1-0.8*(shadeobj.x-realobj.x)/flip_axis;
			}
			
		}
	}
}